home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 501-525 / disk_519 / oaklisp / src.lzh / instruction-table.oak < prev    next >
Text File  |  1988-11-10  |  1KB  |  39 lines

  1. ;;; Copyright (C) 1988 Kevin Lang & Barak Pearlmutter, CMU Oaklisp Project.
  2.  
  3. ;;; Dump a table of all the instructions in a format suitable for
  4. ;;; compilation into the emulator.
  5.  
  6. (let ((aux (lambda (s instr i)
  7.          (format s "    \"~S\"," instr)
  8.          (if (= (modulo i 10) 0)
  9.          (format s "        /* ~D */~%" i)
  10.          (format s "~%")))))
  11.  
  12.   (define (dump-instruction-table f)
  13.  
  14.     (let ((t0 (make simple-vector %argless-instructions))
  15.       (t1 (make simple-vector %arged-instructions)))
  16.  
  17.       (dolist (x (list-type opcode-descriptor-hash-table))
  18.     (destructure* (instr opcode argfield . #t) x
  19.       (cond ((= opcode 0) (set! (nth t0 argfield) instr))
  20.         (else (set! (nth t1 opcode) instr)))))
  21.  
  22.       (with-open-file (s f out)
  23.  
  24.     (format s "#ifndef FAST~%~%")
  25.  
  26.     (format s "char *ArglessInstrs[] = {~%")
  27.     (dotimes (i %argless-instructions)
  28.       (aux s (nth t0 i) i))
  29.     (format s "};~%~%")
  30.  
  31.     (format s "char *Instrs[] = {~%")
  32.     (dotimes (i %arged-instructions)
  33.       (aux s (nth t1 i) i))
  34.     (format s "};~%~%")
  35.  
  36.     (format s "#endif FAST~%~%")))))
  37.  
  38. ;;; eof
  39.